package com.example.personalizededucationsystem.dto.dto;

import com.example.personalizededucationsystem.dto.response.ClassResponse;
import com.example.personalizededucationsystem.model.Class;

import java.time.Instant;

public class ClassResponseDto {
    private Long classId;
    private String className;
    private String subject;
    private String invitationCode;
    private String description;
    private Instant createdAt;
    private String teacherName;

    public static ClassResponse fromEntity(Class myClass) {
        ClassResponse response = new ClassResponse();
        response.setClassId(myClass.getClassId());
        response.setClassName(myClass.getClassName());
        response.setSubject(myClass.getSubject());
        response.setInvitationCode(myClass.getInvitationCode());
        response.setDescription(myClass.getDescription());
        response.setCreatedAt(myClass.getCreatedAt());
        if (myClass.getTeacher() != null) {
            response.setTeacherName(myClass.getTeacher().getNickname());
        }
        return response;
    }

}
